package com.gs.spring.core;

import java.util.Date;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.springframework.stereotype.Component;

import com.gs.spring.core.util.Timestamp;

@Component
public class SimpleBean {
	public SimpleBean() {
		creationDate = new Date();
		System.out.println("____________________");
		System.out.println("Creating default");
		System.out.println("____________________");
	}
	String name;
	public SimpleBean(String name) {
		creationDate = new Date();
		System.out.println("__________________________________________________");
		System.out.println("Creating bean with single argument constructor...");
		System.out.println("__________________________________________________");
		this.name = name;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Timestamp
	Date creationDate;
	
	@PostConstruct
	public void initialize(){
		System.out.println("Initializing bean " + getClass());
	}
	
	@PreDestroy
	public void cleanUp(){
		System.out.println("Cleaning up bean " + getClass());
	}
	
	@Override
	public String toString() {
		return "Bean was created at " + this.creationDate;
	}
	
}
